<?php
/**
* MenuView.php
* Handles views for menu handling.
*/

class MenuView
{
	// -------------------------------------- //
	/**
	* Functions
	* Various functions to show diffrent views depending on the event.
	*/
	
	/**
	* DrawInputMenuView
	* Takes the input from user
	*
 	*/
	public function DrawInputMenuView()
	{
		$xhtml = 
			'<div>
				<form action="" method="POST">
					Menuname:<br/>
					<input type="text" name="menuName"/>
					<input type="submit" name="submitMenuName" value="Spara" />
				</form>
			 </div>';
			 
		return $xhtml;
	}
	
	/**
	* DrawAllMenus
	* Show all menu from the database
	*
	* Array $menuArray containing menu references from database
	*
 	*/
	public function DrawAllMenus( $menusArray )
	{
		$xhtml = '';
		
		foreach($menusArray as $menu) 
		{
			$xhtml .= '
			<form method="GET" action="">
				<strong>ID: </strong><span>' . $menu->GetMenuID() . '</span><br/>
				<strong>Name: </strong><span>' . $menu->GetName() . '</span>
				<input type="submit" name="deleteMenu" value="Radera"/>
				<input type="hidden" name="deleteMenuID" value="' . $menu->GetMenuID() . '"/><br/><br/>
			</form>';
		}
		
		return $xhtml;
	}
	
	public function IsMenuNameSet()
	{
		if( isset( $_POST['menuName'] ) && ( $_POST['menuName'] != null ) )
		{
			return true;
		}
		return false;
	}
	
	public function GetMenuName()
	{
		return $_POST['menuName'];
	}
	
	public function IsDeleteMenuSet()
	{
		if( isset( $_GET['deleteMenuID'] ) )
		{
			return true;
		}
		return false;
	}
	
	public function GetDeleteMenu()
	{
		return $_GET['deleteMenuID'];
	}
	
}